﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace peonwar
{
    public class Timer
    {
        public int ElapsedTime;
        public int Duration;
        public int startedTime;

        public static bool pause;
        public static int GeneralTime;

        public Timer(int duration) // en secondes
        {
            startedTime = GeneralTime;
            ElapsedTime = 0;
            Duration = duration;
            pause = false;
        }

        public bool UpdateTimer()
        {
            if (!pause)
            {
                if (startedTime <= GeneralTime - 1000)
                {
                    startedTime = GeneralTime;
                    this.ElapsedTime++;
                }
                return (ElapsedTime >= Duration);
            }
            return false;
        }

        public void RestartTimer()
        {
            this.ElapsedTime = 0;
        }
    }
}
